package logic

import (
	"context"
	"zhihu/zhihurpc/zhihurpc"

	"zhihu/api/internal/svc"
	"zhihu/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProblmTopListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewProblmTopListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProblmTopListLogic {
	return &ProblmTopListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ProblmTopListLogic) ProblmTopList(req *types.ProblmTopListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.Zhihu.ProblemaTopList(l.ctx, &zhihurpc.ProblemaTopListRequest{})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "热度前十展示成功",
		Data:    list,
		Code:    200,
	}, nil

}
